#include <iostream>

struct BaseComponent {
  typedef int Family;
  static Family family_counter_;
};
BaseComponent::Family BaseComponent:: family_counter_ = 0;
template <typename Derived>
struct Component:public BaseComponent{
  static Family family();
};

struct Other {
  template <typename C>
  static BaseComponent::Family component_family() {
    return Component<typename std::remove_const<C>::type>::family();
  }
  template <typename C>
  void printFamily() {
    auto f1 = component_family<C>();
    std::cout << f1 << std::endl;
  };
  struct Nint : public Component<int>{
  };

  struct Ndouble : public Component<double>{
  };
};

template <typename C>
BaseComponent::Family Component<C>::family() {
  static Family family = ++family_counter_;
  return family;
}

int main() {
  Other o;
  o.printFamily<Other::Ndouble>();
  o.printFamily<Other::Nint>();
  o.printFamily<Other::Ndouble>();
  // 1 1 2 1 2
  return 0;
}
